<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Safeips extends Model
{
    protected $table='safe_ips';
    protected $primaryKey='id';

    public static function insertSafeIps($ip,$links_id,$users_lists,$status)
    {
        return self::insert([
            'ip' => $ip,
            'links_id' => $links_id,
            'users_lists' => $users_lists,
            'status' => $status,
            'created_at' => time()
        ]);
    }

    public static function getSafeIps($links_id,$users_lists)
    {
        $query = self::query();
        if (!empty($links_id)) $query->where("links_id",$links_id);
        if (!empty($users_lists)) $query->where("users_lists","like","%".$users_lists."%");
        return $query->orderBy("id","DESC")->paginate(25);
    }


}
